package com.wangijun.yuan.web.api;


import com.wangijun.yuan.web.base.CommonPage;
import com.wangijun.yuan.web.base.CommonResult;
import com.wangijun.yuan.web.model.dto.RankingArtQryParam;
import com.wangijun.yuan.web.model.dto.RankingTagQryParam;
import com.wangijun.yuan.web.model.dto.RankingTopicQryParam;
import com.wangijun.yuan.web.model.dto.RankingUserQryParam;
import com.wangijun.yuan.web.model.vo.MainArticleVO;
import com.wangijun.yuan.web.model.vo.TagInfoVO;
import com.wangijun.yuan.web.model.vo.TopicInfoVO;
import com.wangijun.yuan.web.model.vo.UserInfoVO;
import com.wangijun.yuan.web.service.ArticleService;
import com.wangijun.yuan.web.service.TagInfoService;
import com.wangijun.yuan.web.service.TopicInfoService;
import com.wangijun.yuan.web.service.UserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@Tag(name = "10-排行页面相关接口")
@RestController
@RequiredArgsConstructor
@RequestMapping("/ranking")
public class RankingController {
    private final ArticleService articleService;
    private final UserService userService;
    private final TagInfoService tagInfoService;
    private final TopicInfoService topicInfoService;

    @Operation(summary = "文章榜",description = "阅读数量榜单，收藏数量榜单")
    @PostMapping("/article")
    CommonResult<CommonPage<MainArticleVO>> rankArticle(@RequestBody RankingArtQryParam param) {
        return CommonResult.data(articleService.rankArticle(param));
    }


    @Operation(summary = "用户阅读榜单",description = "用户阅读数量排行榜")
    @PostMapping("/user")
    CommonResult<CommonPage<UserInfoVO>> rankingUser(@RequestBody RankingUserQryParam param) {
        return CommonResult.data(userService.rankingUser(param));
    }

    @Operation(summary = "标签阅读榜单",description = "标签阅读数量排行榜")
    @PostMapping("/tag")
    CommonResult<CommonPage<TagInfoVO>> rankingTag(@RequestBody RankingTagQryParam param) {
        return CommonResult.data(tagInfoService.rankingTag(param));
    }

    @Operation(summary = "话题阅读榜单",description = "话题阅读数量排行榜")
    @PostMapping("/topic")
    CommonResult<CommonPage<TopicInfoVO>> rankingTopic(@RequestBody RankingTopicQryParam param) {
        return CommonResult.data(topicInfoService.rankingTopic(param));
    }
}
